package kr.co.doriclassic.pro21;

class BankAccount {
	private int balance;
	
	public int deposit(int amount){
		return balance += amount;
	}
	public int withdraw(int amount) throws NegativeBalanceException{
		if(amount>balance)
			throw (new NegativeBalanceException("잔액부족"));
		else
			return balance -= amount;
	}
}

class NegativeBalanceException extends Exception{
	public NegativeBalanceException(String message) {
		super(message);
	}	
}

public class BankAccountTest {
	public static void main(String[] args) {
		BankAccount b = new BankAccount();
		System.out.println("잔액: "+b.deposit(10000));
		try {
			System.out.println("잔액: "+b.withdraw(12000));
		} catch (NegativeBalanceException e) {
			System.out.println(e.getMessage());
		}
	}
}

